package com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.po.enhanced;

import com.homedo.common.dao.bean.po.enhanced.base.BaseEnhanced;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.enums.forroute.StatusEnum4Route;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.po.Route;
import org.springframework.beans.BeanUtils;

import java.util.List;

/**
 * @author 作者 jgshun
 * @date 创建时间 2018年09月18日 11时30分20秒
 */
public class RouteEnhanced extends BaseEnhanced implements Comparable<RouteEnhanced> {
    public RouteEnhanced(Route route) {

        BeanUtils.copyProperties(route, this);

        //自动生成 细微误差自己调整

        if (route.getServiceId() != null) {
            RouteServiceEnhanced routeServiceEnhanced = new RouteServiceEnhanced();
            routeServiceEnhanced.setId(route.getServiceId());
            this.routeServiceEnhanced = routeServiceEnhanced;
        }
        if (route.getStatus() != null) {
            this.status = StatusEnum4Route
                    .getStatusEnumByCode(route.getStatus().shortValue());
        }
        if (route.getDomainRouteId() != null) {
            RouteDomainEnhanced routeDomainEnhanced = new RouteDomainEnhanced();
            routeDomainEnhanced.setId(route.getDomainRouteId());
            this.routeDomainEnhanced = routeDomainEnhanced;
        }
    }

    public RouteEnhanced() {
    }

    private java.lang.String id;
    private java.lang.String applicationName;
    private java.lang.String path;
    private RouteServiceEnhanced routeServiceEnhanced;
    private java.lang.Boolean stripPrefix;
    private java.lang.Boolean retryable;
    private java.lang.Boolean customSensitiveHeaders;
    private java.lang.String sensitiveHeaders;
    private StatusEnum4Route status;
    private java.lang.Double sort;
    private RouteDomainEnhanced routeDomainEnhanced;
    private java.util.Date createTime;
    private java.util.Date updateTime;
    private java.lang.String comment;
    private java.lang.Boolean addHostHeader;
    private java.lang.String addPrefix;

    private List<RouteVersionEnhanced> routeVersionEnhanceds;//版本列表

    public java.lang.String getId() {
        return id;
    }

    public void setId(java.lang.String id) {
        this.id = id;
    }

    public java.lang.String getApplicationName() {
        return applicationName;
    }

    public void setApplicationName(java.lang.String applicationName) {
        this.applicationName = applicationName;
    }

    public java.lang.String getPath() {
        return path;
    }

    public void setPath(java.lang.String path) {
        this.path = path;
    }

    public RouteServiceEnhanced getRouteServiceEnhanced() {
        return routeServiceEnhanced;
    }

    public void setRouteServiceEnhanced(RouteServiceEnhanced routeServiceEnhanced) {
        this.routeServiceEnhanced = routeServiceEnhanced;
    }

    public java.lang.Boolean getStripPrefix() {
        return stripPrefix;
    }

    public void setStripPrefix(java.lang.Boolean stripPrefix) {
        this.stripPrefix = stripPrefix;
    }

    public java.lang.Boolean getRetryable() {
        return retryable;
    }

    public void setRetryable(java.lang.Boolean retryable) {
        this.retryable = retryable;
    }

    public java.lang.Boolean getCustomSensitiveHeaders() {
        return customSensitiveHeaders;
    }

    public void setCustomSensitiveHeaders(java.lang.Boolean customSensitiveHeaders) {
        this.customSensitiveHeaders = customSensitiveHeaders;
    }

    public java.lang.String getSensitiveHeaders() {
        return sensitiveHeaders;
    }

    public void setSensitiveHeaders(java.lang.String sensitiveHeaders) {
        this.sensitiveHeaders = sensitiveHeaders;
    }

    public StatusEnum4Route getStatus() {
        return status;
    }

    public void setStatus(StatusEnum4Route status) {
        this.status = status;
    }

    public java.lang.Double getSort() {
        return sort;
    }

    public void setSort(java.lang.Double sort) {
        this.sort = sort;
    }

    public RouteDomainEnhanced getRouteDomainEnhanced() {
        return routeDomainEnhanced;
    }

    public void setRouteDomainEnhanced(RouteDomainEnhanced routeDomainEnhanced) {
        this.routeDomainEnhanced = routeDomainEnhanced;
    }

    public String getAddPrefix() {
        return addPrefix;
    }

    public void setAddPrefix(String addPrefix) {
        this.addPrefix = addPrefix;
    }

    public java.util.Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(java.util.Date createTime) {
        this.createTime = createTime;
    }

    public java.util.Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(java.util.Date updateTime) {
        this.updateTime = updateTime;
    }

    public java.lang.String getComment() {
        return comment;
    }

    public void setComment(java.lang.String comment) {
        this.comment = comment;
    }

    public List<RouteVersionEnhanced> getRouteVersionEnhanceds() {
        return routeVersionEnhanceds;
    }

    public void setRouteVersionEnhanceds(List<RouteVersionEnhanced> routeVersionEnhanceds) {
        this.routeVersionEnhanceds = routeVersionEnhanceds;
    }

    @Override
    public int compareTo(RouteEnhanced o) {
        return (this.sort < o.sort.doubleValue()) ? -1 : ((this.sort == o.sort.doubleValue()) ? 0 : 1);
    }

    public Boolean getAddHostHeader() {
        return addHostHeader;

    }

    public void setAddHostHeader(Boolean addHostHeader) {
        this.addHostHeader = addHostHeader;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RouteEnhanced that = (RouteEnhanced) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (applicationName != null ? !applicationName.equals(that.applicationName) : that.applicationName != null)
            return false;
        if (path != null ? !path.equals(that.path) : that.path != null) return false;
        if (routeServiceEnhanced != null ? !routeServiceEnhanced.equals(that.routeServiceEnhanced) : that.routeServiceEnhanced != null)
            return false;
        if (stripPrefix != null ? !stripPrefix.equals(that.stripPrefix) : that.stripPrefix != null) return false;
        if (retryable != null ? !retryable.equals(that.retryable) : that.retryable != null) return false;
        if (customSensitiveHeaders != null ? !customSensitiveHeaders.equals(that.customSensitiveHeaders) : that.customSensitiveHeaders != null)
            return false;
        if (sensitiveHeaders != null ? !sensitiveHeaders.equals(that.sensitiveHeaders) : that.sensitiveHeaders != null)
            return false;
        if (status != that.status) return false;
        if (sort != null ? !sort.equals(that.sort) : that.sort != null) return false;
        if (routeDomainEnhanced != null ? !routeDomainEnhanced.equals(that.routeDomainEnhanced) : that.routeDomainEnhanced != null)
            return false;
        if (addHostHeader != null ? !addHostHeader.equals(that.addHostHeader) : that.addHostHeader != null)
            return false;
        if (addPrefix != null ? !addPrefix.equals(that.addPrefix) : that.addPrefix != null) return false;
        return routeVersionEnhanceds != null ? routeVersionEnhanceds.equals(that.routeVersionEnhanceds) : that.routeVersionEnhanceds == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (applicationName != null ? applicationName.hashCode() : 0);
        result = 31 * result + (path != null ? path.hashCode() : 0);
        result = 31 * result + (routeServiceEnhanced != null ? routeServiceEnhanced.hashCode() : 0);
        result = 31 * result + (stripPrefix != null ? stripPrefix.hashCode() : 0);
        result = 31 * result + (retryable != null ? retryable.hashCode() : 0);
        result = 31 * result + (customSensitiveHeaders != null ? customSensitiveHeaders.hashCode() : 0);
        result = 31 * result + (sensitiveHeaders != null ? sensitiveHeaders.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (sort != null ? sort.hashCode() : 0);
        result = 31 * result + (routeDomainEnhanced != null ? routeDomainEnhanced.hashCode() : 0);
        result = 31 * result + (addHostHeader != null ? addHostHeader.hashCode() : 0);
        result = 31 * result + (addPrefix != null ? addPrefix.hashCode() : 0);
        result = 31 * result + (routeVersionEnhanceds != null ? routeVersionEnhanceds.hashCode() : 0);
        return result;
    }
}